package com.t2c.tibetantochinese.me;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

import com.t2c.tibetantochinese.R;
import com.t2c.tibetantochinese.base.BaseActivity;
import com.t2c.tibetantochinese.common.HttpRequestManager;
import com.t2c.tibetantochinese.utils.CommonUtil;
import com.t2c.tibetantochinese.views.TitleBar;

/**
 * Created by zoulu on 17/6/6.
 * 二维码界面
 */
public class CodeActivity extends BaseActivity {

    private ImageView imageView;

    @Override
    protected int getContentViewResId() {
        return R.layout.code_layout;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init();
        initData();
    }

    private void init() {
        imageView = (ImageView)findViewById(R.id.code);
        TitleBar titleBar = (TitleBar)findViewById(R.id.titlebar);
        titleBar.setOnLeftListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        if(CommonUtil.isChinese(this)) {
            titleBar.setTitle(getResources().getString(R.string.code));
        }else{
            titleBar.getTitle().setTypeface(CommonUtil.getTibetanType(this));
            titleBar.setTitle(getResources().getString(R.string.tcode));
        }
    }

    private void initData(){
        Bitmap qrBitmap = CommonUtil.generateBitmap(HttpRequestManager.downloadURL,400, 400);
        imageView.setImageBitmap(qrBitmap);
    }
}
